<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1,user-scalable=no">
		<title>销售订单</title>
		<link rel="stylesheet" href="$!rc.contextPath/common/common.css" />
		<link rel="stylesheet" type="text/css" href="$!rc.contextPath/css/myorder1.css" />
		<link rel="stylesheet" href="$!rc.contextPath/common/dropload.css" />
		<style type="text/css">
			.comment-img{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				padding:1rem;
			}
			.img-item{
				width:23%;
			}
			.img-item img{
				width:100%;
				max-height: 100%;
			}
			.comment{
				display: block !important;
			}
			.comment:after{
				display: block;
				content: "";
				clear: both;
			}
			.comment>div{
				float:left;
			}
			.comment .order-content-text{
				width:66%;
			}
			.order-price>p{
				height:initial !important;
				margin-bottom: 0 !important;
				text-align: left;
			}
			.order-price>p:nth-child(1)>span{
				color:#ff4343 !important;
			}
			.order-oldprice{
				font-size:1.2rem;
			}
		</style>
	</head>

	<body>
		<!--顶部-->
		<div class="title text-center">
			<a onClick="javascript:window.history.go(-1)"><</a>
			销售订单
		</div>
		<ul class="headlines-title">
			<li class="active" onclick="f_init(1)"><div>已发货</div><span></span></li>
			<li  onclick="f_init(2)"><div>待发货</div><span></span></li>
			<li  onclick="f_init(3)"><div>退款</div><span></span></li>
		</ul>
		<div class="content order-business">
			<!--已发货-->
			<ul class="lists">
				
			</ul>	
		</div>
		<!-- <div class="content order-business">
			待发货
			<ul>
				<li>
					<ul class="order-store">
						<div class="order-title">
							左边标题
							<a href="#" class="order-title-left">
								<span>2255服饰</span>
								<i class="iconfont icon-dayuhao"></i>
							</a>
							右边提醒
							<div class="order-title-right">
								买家已付款
							</div>
						</div>
						<li>
							<div class="order-content">
								<div class="order-content-img">
									<img src="img/shoes.png" />
								</div>
								<div class="order-content-text">
									<p>商品介绍商品简介点击商品进入详情页面</p>
									！！！勿删，以便之后增加
									<div>
										<span>颜色：</span><span class="goods-color">白黑</span><span>; 尺寸：</span><span class="goods-size">均码</span>
									</div>
								</div>
								<div class="order-price">
									<p><span>￥</span><span class="order-newprice">39.90</span></p>
									<p><span>￥</span><span class="order-oldprice">49.90</span></p>
									<div class="order-quantity">
										x1
									</div>
								</div>
							</div>
							<div class="order-total-price">
								<div></div>
								<div>
									<span>合计：</span><span><span>￥</span><span class="total-price">0.00</span></span>
									<span>（含运费￥<span class="order-freight">0.00</span>）</span>
								</div>
							</div>
							<div class="order-btn">
								<div></div>
								<div class="order-btn-button">
									<div class="contain">
									    <div class="fixWidth">
									        <div class="demo">
									            <input class="cancel-order" id="trigger1" type="button" value="查看物流" />
									        </div>
									    </div>
									</div>
									<input class="order-btn-active" type="button" onclick="window.location.href='order-confirmdelivery.html'" value="确认发货" />
								</div>
							</div>
						</li>
					</ul>
				</li>
			</ul>	
		</div>
		<div class="content order-business">
			退款
			<ul>
				<li>
					<ul class="order-store">
						<div class="order-title">
							左边标题
							<a href="#" class="order-title-left">
								<span>2255服饰</span>
								<i class="iconfont icon-dayuhao"></i>
							</a>
							右边提醒
							<div class="order-title-right">
								买家已付款
							</div>
						</div>
						<li>
							<div class="order-content">
								<div class="order-content-img">
									<img src="img/shoes.png" />
								</div>
								<div class="order-content-text">
									<p>商品介绍商品简介点击商品进入详情页面</p>
									！！！勿删，以便之后增加
									<div>
										<span>颜色：</span><span class="goods-color">白黑</span><span>; 尺寸：</span><span class="goods-size">均码</span>
									</div>
								</div>
								<div class="order-price">
									<p><span>￥</span><span class="order-newprice">39.90</span></p>
									<p><span>￥</span><span class="order-oldprice">49.90</span></p>
									<div class="order-quantity">
										x1
									</div>
								</div>
							</div>
							<div class="order-total-price">
								<div></div>
								<div>
									<span>合计：</span><span><span>￥</span><span class="total-price">0.00</span></span>
									<span>（含运费￥<span class="order-freight">0.00</span>）</span>
								</div>
							</div>
							<div class="order-btn">
								<div></div>
								<div class="order-btn-button">
									<div class="contain">
									    <div class="fixWidth">
									        <div class="demo">
									            <input class="cancel-order" id="trigger1" type="button" value="查看物流" />
									        </div>
									    </div>
									</div>
									<input class="order-btn-active" type="button" onclick="window.location.href='order-confirmdrawback.html'" value="确认退款" />
								</div>
							</div>
						</li>
					</ul>
				</li>
			</ul>	
		</div> -->
		
		<!--footer底部-->
		<!-- <footer><span>~ 到底了 ~</span></footer> -->
		<!--footer底部 end-->
		<script src="$!rc.contextPath/common/jquery-1.8.3.min.js" type="text/javascript"></script>
		<script src="$!rc.contextPath/js/myorder1.js" type="text/javascript"></script>
		<script src="$!rc.contextPath/common/dropload.min.js"></script>
		<script type="text/javascript">
		$(function(){
			f_init(1);
		})
		
		function f_init(orderState){
		$(".lists").empty();
		$(".dropload-down").remove();
		
		var counter = 0;
	    // 每页展示4个
	    var num = 5;
	    var pageStart = 0,pageEnd = 0;
	
	    // dropload
	    $('.content').dropload({
	        scrollArea : window,
	        domUp : {
	            domClass   : 'dropload-up',
	            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
	            domUpdate  : '<div class="dropload-update">↑释放更新</div>',
	            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
	        },
	        domDown : {
	            domClass   : 'dropload-down',
	            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
	            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
	            domNoData  : '<div class="dropload-noData">~没有更多订单了~</div>'
	        },
	        loadDownFn : function(me){
	            $.ajax({
	                type: 'POST',
	                url: '$!rc.contextPath/order/saleOrderList',
	                data : {
	                	orderState : orderState,
	                	startIndex : pageStart,
	                	pageSize : num
	                },
	                dataType: 'json',
	                success: function(data){
	                    var result = '';
	                    counter++;
	                    pageEnd = num * counter;
	                    pageStart += num;
	                    if(data.code == '0'){
	                    	var list = data.data;
	                    	console.log(list);
	                    	for(var i = 0; i < list.length; i++){
	                    		var state;
	                    		if(list[i].order_state == '2'){
	                    			state = '待发货';
	                    		}else if(list[i].order_state == '3' || list[i].order_state == '4' || list[i].order_state == '5'){
	                    			if(list[i].delivery_addr_id != 0){
	                    				state = '已发货';
	                    			}else{
	                    				state = '门店自提';
	                    			}
	                    		}else if(list[i].order_state == '6'){
	                    			state = '退款中';
	                    		}else if(list[i].order_state == '7'){
	                    			state = '已退款';
	                    		}
	                    		
		                        result += '<li><ul class="order-store"><div class="order-title"><a href="#" class="order-title-left"><span>参境39度(' + list[i].store_name + ')</span>' + 
		                        			'<i class="iconfont icon-dayuhao"></i></a><div class="order-title-right">' + state + '</div></div><li >';
		                        
		                        var skuList = list[i].skuList;
		                        for(var j = 0; j < skuList.length; j++){
		                        	result += '<div class="order-content" val="' + list[i].order_id + '" onclick="f_detail(this)"><div class="order-content-img"><img src="http://app.tmaipay.com/' + skuList[j].attach_path + '" /></div><div class="order-content-text">' + 
		                        				'<p>' + skuList[j].sku_name + '</p></div><div class="order-price"><p><span>¥</span><span class="order-newprice">' + skuList[j].sku_price + '</span></p>' + 
		                        				'<p><span>¥</span><span class="order-oldprice">' + skuList[j].old_price + '</span></p><div class="order-quantity">×' + skuList[j].sku_account + '</div></div></div>';
		                        				
		                        }
		                        
								var pointStr = "";
		                        
		                        if(list[i].order_point > 0){
		                        	pointStr = "<span style=\"font-size: 12px;color: #828282;\">(积分抵扣" + list[i].order_point + "元)</span>";
		                        }
		                        
		                        result += '<div class="order-total-price"><div></div><div><span>合计：</span><span><span>¥</span><span class="total-price">' + list[i].real_amount + ' ' + pointStr + '</span></span></div></div>';
		                        
		                        if(list[i].order_state == '2'){
		                        	result += '<div class="order-btn"><div></div><div class="order-btn-button"><input class="order-btn-active" val="' + list[i].order_id + '" type="button" onclick="f_confirm(this)" value="确认发货" /></div></div>';
	                    		}else if(list[i].order_state == '6'){
	                    			result += '<div class="order-btn"><div></div><div class="order-btn-button"><input class="order-btn-active" val="' + list[i].order_id + '" type="button" onclick="f_refund(this)" value="确认退款" /></div></div>';
	                    		}
		                        
		                        result += '</li></ul></li>';
		                        
	                    	}
	                    	
	                    	if(list.length < 5){
	                            // 再往下已经没有数据
	                            // 锁定
	                            me.lock();
	                            // 显示无数据
	                            me.noData();
	                            //break;
	                        }
	                    }
	
                        $('.lists').append(result);
                        // 每次数据加载完，必须重置
                        me.resetload();
                        
	                },
	                error: function(xhr, type){
	                    alert('网络故障!');
	                    // 即使加载出错，也得重置
	                    me.resetload();
	                }
	            });
	        },
	        threshold : 50
	    });
	}
		
		function f_confirm(obj){
			var orderId = $(obj).attr("val");
			
			window.location.href = '$!rc.contextPath/orderView/orderConfirm?orderId=' + orderId;
		}
		
		function f_refund(obj){
			var orderId = $(obj).attr("val");
			
			window.location.href = '$!rc.contextPath/orderView/orderRefund?orderId=' + orderId;
		}
		
		function f_detail(obj){
			window.location.href = '$!rc.contextPath/orderView/detail?orderId=' + $(obj).attr("val");
		}
		</script>
	</body>
</html>